<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: languages.php 508 2014-01-31 21:18:56Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 508 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2014-01-31 21:18:56 +0000 (Fri, 31 Jan 2014) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(!isset($lng) && !is_object($lng)) {
	include(DIR_WS_CLASSES.'class.language.php');
	$lng = new language;
}

$languages_string = '';
$count_lng = '';
reset($lng->catalog_languages);

if(sizeof($lng->catalog_languages) > 1) {
	require_once DIR_FS_INC.'inc.collect_get.php';
	
	$box_smarty = new Smarty();

	if(!CacheCheck()) {
		$cache = false;
		$box_smarty->caching = false;

	} else {
		$cache = true;
		$box_smarty->caching = true;
		$box_smarty->cache_lifetime = CACHE_LIFETIME;
		$box_smarty->cache_modified_check = CACHE_CHECK;
		$cache_id = 'box_languages'.collect_get().'_'.$_SESSION['language'].'_'.$_SESSION['customers_status']['customers_status_id'].'_';
	}

	if(!$box_smarty->isCached(CURRENT_TEMPLATE.'/boxes/box_languages.html', $cache_id) || !$cache){

		if(MODULE_SEO_URL_INDEX_STATUS == 'True' && !is_object($seo_url)) {
			require_once DIR_FS_INC.'inc.seo_url.php';
			$seo_url = new SeoUrl();
		}

		if(basename($PHP_SELF) != 'seo_url.php')
			$uri = basename($PHP_SELF);
		else
			$uri = $_SERVER['REQUEST_URI'];

		while(list($key, $value) = each($lng->catalog_languages)) {
			$count_lng++;
			if(MODULE_SEO_URL_INDEX_STATUS == 'True') {
				if(isset($_GET['cPath']) && !isset($_GET['products_id'])) {
					$cat_tmp = explode('_', $_GET['cPath']);
					$cat = array_reverse($cat_tmp);
					$uri = $seo_url->getLanguageChangeLink('index.php', 'cPath='.$cat[0].'&language='.$key, $request_type);
				} elseif(isset($_GET['products_id']))
					$uri = $seo_url->getLanguageChangeLink(FILENAME_PRODUCT_INFO, 'products_id='.$_GET['products_id'].'&language='.$key, $request_type);
				elseif(isset($_GET['coID']) && $_GET['coID'] != 5)
					$uri = $seo_url->getLanguageChangeLink(FILENAME_CONTENT, 'coID='.$_GET['coID'].'&language='.$key, $request_type);
				else
					$uri = DIR_WS_CATALOG.$key.'/';
			} else
				$uri =  href_link($uri ,'language='.$key);

			if($key != $_SESSION['language_code'])
				$languages_string .= ' <a href="'.$uri.'" title="'.$value['name'].'">'.image('lang/'. $value['directory'] .'/'.$value['image'], $value['name']).'</a> ';
		}
	}

	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');
	if(!$cache)
		$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_languages.html');
	else
		$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_languages.html', $cache_id);
}